package view.normalview;

import java.awt.Component;
import java.awt.EventQueue;
import javax.xml.xpath.*;
import java.awt.Frame;

import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JMenu;

import controller.Filecontroller;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.io.File;
import java.io.IOException;


public class MainWindow {

	private JFrame frame;
	private Filecontroller controller=new Filecontroller(this);
	
	/**
	 * Create the application.
	 */
	public MainWindow() {
		initialize();
	}
private void addcenterpanel(Component panel){
		frame.add(panel);
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frame = new JFrame();
		frame.setBounds(100, 100, 450, 300);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		JMenuBar menuBar = new JMenuBar();
		frame.setJMenuBar(menuBar);
		
		JMenu mnFile = new JMenu("File");
		menuBar.add(mnFile);
		final FileChooser fcd=new FileChooser();
	
		
		JMenuItem mntmOpen = new JMenuItem("open");
		frame.setVisible(true);
		mntmOpen.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				JFileChooser fc = new JFileChooser();
				fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
				fc.showOpenDialog(fcd);
				File file=fc.getSelectedFile();
				controller.open(file);
					
					
			
			
			}
		});
		mntmOpen.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				
			}
		});
		mnFile.add(mntmOpen);
	}
	public JFrame getFrame() {
		return frame;
	}
	public void setFrame(JFrame frame) {
		this.frame = frame;
	}
	
	

}